<template>
    <div>
        <div>
            <el-input class="searchInput" 
                    clearable
					@clear="keywordClear"
                    v-model="keyword"
                    placeholder="请输入学号查询"
                    @keydown.enter.native="doSearch"
                    prefix-icon="el-icon-search">
            </el-input>
            <el-button icon="el-icon-search" type="primary" @click="doSearch">搜索</el-button> 
        </div>
        <div class="infoMain">
            <el-table   
                        :data="allotStudents"
                        stripe
                        border
                        style="width: 55%">
                    <el-table-column
                            prop="studentId" label="学号" width="130">
                    </el-table-column>
                    <el-table-column
                            prop="sname" label="姓名" width="80">
                    </el-table-column>
                    <el-table-column
                            prop="gender" label="性别" width="60">
                    </el-table-column>
                    <el-table-column
                            prop="mname" label="专业" width="160">
                    </el-table-column>
                    <el-table-column
                            prop="level" label="学级" width="60">
                    </el-table-column>
                    <el-table-column
                            prop="cname" label="班级" width="90">
                    </el-table-column>
                    <el-table-column
                            prop="telephone" label="电话">
                    </el-table-column>
            </el-table>
        </div>
		<div style="width: 55%; display: flex;justify-content: flex-end;">
		    <el-pagination
				@current-change="currentChange"
				:current-page="current"
		        :page-size="size"
		        layout="total, prev, pager, next"
		        :total="total">
		    </el-pagination>
		</div>
    </div>
</template>

<script>
    export default {
        data () {
            return {
                allotStudents:[],
				keyword:'',
				current: 1,
				size: 10,
				total: 0,
				
            }
        },
		mounted() {
			this.initAllot();
		},
        methods:{
            initAllot(){
				let url = '/information/allot/?current=' + this.current + '&size=' + this.size + '&keyword=' + this.keyword;
				this.getRequest(url).then(resp => {
					if(resp){
						this.allotStudents = resp.data;
						this.total = resp.total;
					}
				})
			},
			keywordClear(){
				this.current = 1;
				this.initAllot();
			},
			doSearch(){
				this.current = 1;
				this.initAllot();
            },
			currentChange(val){
				this.current = val;
				this.initAllot();
			},
        }
    }
</script>

<style scoped>
    .searchInput{
        width: 300px;
        margin-right: 8px;
    }
    .infoMain{
        margin-top: 10px;
    }
</style>